﻿using CommunicationProtocol.dto;
using server.filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommunicationProtocol.filters
{
    /**
     * 用于把命令翻译为字节数组
     */ 
    public class CommandEncoder : NetFilter
    {
        public void invoke(object buffer, InvocationChain invocationChain)
        {
            if (buffer is Command)
            {

                invocationChain.invoke(
                    ((Command)buffer).GetBytes()
                    );
            }
            else {
                invocationChain.invoke(buffer);
            }
        }
    }
}
